-
-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] add a duration custom option type to support arbitrary duration units #21307
base: main
Are you sure you want to change the base?
Conversation
@benjyw: How should I update the Rust option parser for this new option type? I see the following warning:
|
TBH I think the options system types are already too complicated. As an alternative, maybe all durations could be integers representing milliseconds (do we ever actually need microseconds)? Or floats representing seconds? Or just strings with the interpretation done entirely on the consuming side in Python in some helper? If you want to go down this path then the Rust side type should be String, with the interpretation done in Python (similar to what we do for addresses and so on). |
You elude to my ulterior motive here: Uniform treatment from the user's perspective of all duration-typed options. We have some options which are seconds and some which are millis. Converting to Do you consider allowing users to provide a duration string to be too much complication? As it is, users have to figure out what unit the option is using to use the options correctly. Allowing them to just specify what they want could be seen as less complicated. Thoughts? |
What is the migration plan for existing options here - how would you interpret a naked integer? Fail on it after a deprecation period? In any case, if you want to do this, I would not add a type for this in Rust, but have it be a String, and then interpret that string somewhere. Which is what we already do for all sorts of types like Address that are not explicitly handled in Rust. |
Migration thoughts:
|
Add a
duration
custom type for options (and companion classDurationOption
) to support users specifying duration-typed values with a number and a unit. This will allow migrating existing options which takes milliseconds or seconds or some other unit to finally be consistent with one another.E.g., the user can specify
10ms
for 10 milliseconds or50us
for 50 microseconds.